package com.sjgtw.cloud.job.service;

import com.sjgtw.cloud.common.core.exception.job.TaskException;
import com.sjgtw.cloud.job.domain.SysJob;
import org.quartz.SchedulerException;
import java.util.List;

/**
 * <p>Title: 定时任务信息处理--服务层</p>
 * <p>Description: </p>
 *
* @author Admin
 * @date 2020-7-7
 */
public interface ISysJobService {
    /**
     * <p>Title: 获取quartz调度器的计划任务</p>
     * <p>Description: </p>
     *
     * @param job 调度信息
     * @return 调度任务集合
     */
    public List<SysJob> selectJobList(SysJob job);

    /**
     * <p>Title: 通过调度任务ID查询调度信息</p>
     * <p>Description: </p>
     *
     * @param jobId 调度任务ID
     * @return 调度任务对象信息
     */
    public SysJob selectJobById(Long jobId);

    /**
     * <p>Title: 暂停任务</p>
     * <p>Description: </p>
     *
     * @param job 调度信息
     * @return 结果
     */
    public int pauseJob(SysJob job) throws SchedulerException;

    /**
     * <p>Title: 恢复任务</p>
     * <p>Description: </p>
     *
     * @param job 调度信息
     * @return 结果
     */
    public int resumeJob(SysJob job) throws SchedulerException;

    /**
     * <p>Title: 删除任务</p>
     * <p>Description: 删除任务后，所对应的trigger也将被删除</p>
     *
     * @param job 调度信息
     * @return 结果
     */
    public int deleteJob(SysJob job) throws SchedulerException;

    /**
     * <p>Title: 批量删除调度信息</p>
     * <p>Description: 删除任务后，所对应的trigger也将被删除</p>
     *
     * @param jobIds 需要删除的任务ID
     * @return 结果
     */
    public void deleteJobByIds(Long[] jobIds) throws SchedulerException;

    /**
     * <p>Title: 修改任务调度状态</p>
     * <p>Description: </p>
     *
     * @param job 调度信息
     * @return 结果
     */
    public int changeStatus(SysJob job) throws SchedulerException;

    /**
     * <p>Title: 立即运行任务</p>
     * <p>Description: </p>
     *
     * @param job 调度信息
     * @return boolean
     */
    public boolean run(SysJob job) throws SchedulerException;

    /**
     * <p>Title: 新增任务</p>
     * <p>Description: </p>
     *
     * @param job 调度信息
     * @return 结果
     */
    public int insertJob(SysJob job) throws SchedulerException, TaskException;

    /**
     * <p>Title: 更新任务</p>
     * <p>Description: </p>
     *
     * @param job 调度信息
     * @return 结果
     */
    public int updateJob(SysJob job) throws SchedulerException, TaskException;

    /**
     * <p>Title: 校验cron表达式是否有效</p>
     * <p>Description: </p>
     *
     * @param cronExpression 表达式
     * @return 结果
     */
    public boolean checkCronExpressionIsValid(String cronExpression);
}